#include <REGX52.H>
#include <INTRINS.H>

void Delay1ms(unsigned int ms)	//@12.000MHz
{
	unsigned char data i, j;

	while (ms--) 
	{
		i = 2;
		j = 239;
		do
		{
			while (--j);
		} while (--i);
	}
}

void led_running1() {
	while (1) 
	{
		P2 = 0xFE;
		Delay1ms(500);
		
		P2 = 0xFD;
		Delay1ms(500);
		
		P2 = 0xFB;
		Delay1ms(500);
		
		P2 = 0xF7;
		Delay1ms(500);
	
		P2 = 0xEF;
		Delay1ms(500);
		
		P2 = 0xDF;
		Delay1ms(500);
		
		P2 = 0xBF;
		Delay1ms(500);
		
		P2 = 0x7F;
		Delay1ms(500);
	}
}

void led_running2()
{
	unsigned int temp;
	while (1) {
		temp = 0x1;
		
		while (temp <= 0x80) {
			P2 = ~temp;
			temp = temp << 1;
			Delay1ms(500);
		}
	}
}


void main () 
{
	
//	led_running1();

	led_running2();
	
}